package models

type BuildArtifact struct {
	Model
	BuildId int `gorm:"column:build_id" db:"column:build_id" json:"build_id" form:"build_id"`
	Size int64 `gorm:"column:size" db:"column:size" json:"size" form:"size"`
	Name string `gorm:"column:name" db:"column:name" json:"name" form:"name"`
	JenkinsPath string `gorm:"column:jenkins_path" db:"column:jenkins_path" json:"jenkins_path" form:"jenkins_path"`
	SavePath string `gorm:"column:save_path" db:"column:save_path" json:"save_path" form:"save_path"`
}

func GetArtifacts(buildID int) []*BuildArtifact {
	artifacts := make([]*BuildArtifact, 0)
	db.Where("deleted_at = 0").Where("build_id = ?", buildID).Find(&artifacts)
	return artifacts
}

func BatchCreateArtifacts(arts []*BuildArtifact) {
	db.Create(&arts)
}